<%--
  Created by IntelliJ IDEA.
  User: zhangyuan
  Date: 2020-04-08
  Time: 14:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>新建工作</title>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1" />
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <link rel="stylesheet" href="/css/workflow/flowrun/allsearch.css">
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <style>
	
        #headerbox{
            height: 43px;
            line-height: 43px;
        }
        #headerbox .title{
            margin-left: 22px;
            height: 43px;
        }
        #headerbox .title img{
            margin-bottom: 5px;
        }
        #headerbox span{
            float: none;
            display: inline-block;
            height: 43px;
            line-height: 43px;
        }
        .headerTitle{
            margin-left: 5px;
            font-size: 22px;
            color: #333;
            line-height: 18px;
        }
        .color2 {
            color: #50C625;
        }
        .color3 {
            color: #F4A8BD;
        }
        table tr{
            border: none;
        }
        body{
            background: #f6f7f9;
        }
        .head{
            height: auto;
            border: none;
        }
        .tablebox{
            margin-left: -6px;
        }
    </style>
    <style>
        .tab_c{
            background: #f5f5f5;
            border-right: 2px solid #e9f0f5;
        }
        .tab_cone{
            color: #111!important;
        }
        .one_all{
            border: none;
            border-bottom: none;
            background: #f5f7f8 !important;
            border-top: 2px solid #fff!important;
        }
        .one_logo {
            margin-left: 0;
            margin-top: 0;
            float: none;
        }
        .tab_cone .one:nth-child(1) {
            border-top: none;
        }
    </style>
    <style type="text/css">
        #flow_sort_nav > a{
            text-decoration:none;
            color:#666666;
            font-size: 18px;
            font-weight:bold;
        }
        #flow_sort_nav > a:hover {
            text-decoration: none;
            color: #589Fff;
            font-weight: bold;
        }
    </style>
    <style type="text/css">
        .container-fluid{
            width: 100%;
            height:100%;
            overflow:hidden;
        }
        .cont_left{
            background: none !important;
            border-right: none;
        }
        .all_ul{
            width: 100% !important;
            height: 100%;
            margin-left: 0% !important;
            background: #fff;
        }
        .tab_c{
            margin-left: 0% !important;
        }
        .one_all{
            height: 40px !important;
            width: 100% !important;
            border-left: none !important;
            border-right: none !important;
        }
        .one_name{
            margin-left: 5px;
            width: 77%;
            line-height: 40px !important;
            text-align: left;
            color: #333;
            padding-left: 10px;
            text-overflow: inherit;
        }
        .one_name img{
            margin-left: 2px;
        }
        .down_jiao{
            margin-left: 0;
            position: absolute;
            right: 5px;
            margin-top: 15px;
            width: 12px;
            height: 7px;
        }
        .two_all{
            width: 100%;
        }
        #title{
            padding-left: 20px;
        }

        .two_all h1{
            width: 66%;
            margin-left: 0;
            color: #111;
            text-shadow: none;
            padding-left: 55px;
        }

        .cont_left{
            width:15%;
        }
        .cont_rig{
            width:85%;
        }
        .rig_all{
            width:96%;
            height:100%;
            margin:auto;
        }
        .rig_cont ul li{
            width: 99%;
            height: 80px;
            border: 1px solid #cccccc;
            border-radius: 2px;
            background: #f9fbff;
            margin-top: 10px;
        }
        .rig_cont{
            overflow-y: scroll;
            height: 94%;

        }
        .rig_title img,.rig_title h1{
            float:left;
            margin-top:5px;
        }
        .rig_title img{
            margin-top:10px;
        }
        .rig_title h1{
            font-size: 15pt;
            font-weight: normal;
            font-family: Microsoft yahei,Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;
            margin-left: 12px;
            line-height: 35px;
        }
        .rig_left,.rig_mid,.rig_rig{
            float: left;
            height: 100%;
        }
        .rig_rig{
            width:27%;
            font-size: 17px;
        }
        .rig_left{
            /*width: 55%;*/
            width: 100%;
            font-size: 14px;
        }
        .rig_mid{
            width:18%;
            margin-top: -27px;
        }
        .liucheng,.liucheng1,.liucheng2{
            height:100%;
            float: left;
            margin-right:7%;
            cursor: pointer;
        }
        .liucheng img,.liucheng h1,.liucheng1 img,.liucheng1 h1,.liucheng2 img,.liucheng2 h1{
            float:left;
        }
        .rig_rig div{
            width: 49%;
            float: left;
            margin-top: 14px;
            cursor: pointer;
        }
        .xinjian_img{
            margin-left: 39%;
            cursor: pointer;
        }
        .xinjian_h1{
            width: 100%;
            height: 20px;
            text-align: center;
        }
        .rig_left h1{
            font-size: 13pt;
            font-weight: bold;
            margin-left: 12px;
            margin-top: 17px;
            width: 90%;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .rig_left h1:hover{
            color: #2b7fe0;
        }
        .rig_left h2{
            margin-left: 12px;
            color: #b7b8b9;
            margin-top: 5px;
            width:90%;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
        }
        .liucheng h1,.liucheng1 h1,.liucheng2 h1{
            line-height: 80px;
            margin-left: 5px;
        }
        .liucheng img,.liucheng1 img,.liucheng2 img{
            margin-top: 31px;
        }
        .new_work{
            font-size: 22px;
            margin-top: 9px;
        }
        .new-search{
            margin-top:8px !important;
        }
        .one_all{
            background: #f0f4f7 !important;
            position: relative;
        }
        .one_alltwo{
            background: #fff!important;
            height: 40px !important;
            width: 100% !important;
            border-left: none !important;
            border-right: none !important;
            border: none;
            border-bottom: none;
            border-top: 2px solid #fff!important;
            margin-top: 0%;
        }
        .one_alltwo h1{
            font-size: 18px;
            color: #2f8ae3;
        }
        .tab_cone li .one_all:hover{
            background: #b6e0ff !important;
        }
        .tab_cone{
            width: 100% !important;
            height:99% !important;
        }
        .er_img {
            margin-left: 0;
            position: absolute;
            right: 15px;
            margin-top: 15px;
            width: 12px;
            height: 7px;
        }
        #searchbtn,.rig_mid h1,.rig_rig h1{
            cursor: pointer;
        }
        .namenew{
            cursor: pointer;
        }
        /*定义滚动条宽高及背景，宽高分别对应横竖滚动条的尺寸*/
        .rig_cont::-webkit-scrollbar{
            width: 0px;
            height: 16px;
            background-color: #f5f5f5;
        }
        /*定义滚动条的轨道，内阴影及圆角*/
        .rig_cont::-webkit-scrollbar-track{
            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
            border-radius: 10px;
            background-color: #f5f5f5;
        }
        /*定义滑块，内阴影及圆角*/
        .rig_cont::-webkit-scrollbar-thumb{
            /*width: 10px;*/
            height: 20px;
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
            background-color: #555;
        }

        #sort_cont li:hover{
            background: #e8f4fc;
        }
        .quick:hover .xinjian_h1{
            color:#2b7fe0;
        }

        .xiangdao:hover h1{
            color:#2b7fe0;
        }
        .xjxd{
            cursor: pointer;
        }
        #form_select{
            height: 28.4px !important;
        }
        /*一级菜单移入移出样式的改变*/
        .one_all li:hover{
            background:#ccebff;
            cursor:pointer;
        }
        .one_all li:hover h1{
            color:#2f8ae3;
        }
        /*二级菜单移入移出样式的改变*/
        /* .two_menu li:hover{
             background:#ccebff;
             cursor:pointer;
         }
         .two_menu li:hover h1{
             color:#2f8ae3;
         }*/
        .two .two_all:hover{
            color:#2f8ae3;
            background:#ccebff;
            cursor: pointer;
        }
        .menu_change{
            color:#2f8ae3;
        }
        /*三级菜单移入移出样式的改变*/
        .three:hover{
            color:#2f8ae3;
            background:#ccebff;
        }
        .rig_mid h1{
            font-size:16px;
        }
        .rig_mid h1:hover{
            color: #2b7fe0;
        }
        /* .liucheng img, .liucheng1 img, .liucheng2 img{
             margin-top:35px;
         }*/
        .sanji_circle{
            display: none;
        }
        .three{
            background: rgb(232, 244, 252);
        }
        .three h1{
            color: #333;
            text-shadow: none;
        }
        .sanji .three:hover{
            background: #ccebff;
        }
        .two{
            background: none!important;
        }

        /*********************左侧滚动条修改******************************/
        .yiji::-webkit-scrollbar {
            width: 10px;
        }
        .yiji::-webkit-scrollbar-thumb {
            border-radius: 50px;
            background-color: #bfbfbf;
        }
        .yiji::-webkit-scrollbar-track {
            border-radius: 50px;
            background-color: #ffffff;
        }
        .one{
            background: #fff!important;
        }
        .sort_new{
            overflow: hidden;
            margin: 6px auto;
        }
        .rig_rig{
            margin-top: -12px;
            font-size: 13px;
        }
        .toggle{
            width: 80px;
            height: 27px;
            margin-top: 9px;
            margin-left: 30px;
            background: #4d90fe;
            color: white;
            border-radius: 12px;
            border: none;
        }
        .cover_scroll {
            position: absolute;
            top: 0;
            right: 0px;
            height: 100%;
            width: 25px;
            z-index: 1;
            background-color: #fff;
        }
		
    </style>
	<link rel="stylesheet" href="/css/workflow/work/switchWork.css">
</head>
<body>
<%--<button class="toggle">切换视图</button>--%>
<div class="tablebox" style="display: none;position: relative">
    <table width="99%" border="0" cellpadding="0" cellspacing="0" style="margin-top:10px;">
        <tbody>
        <tr>
            <td width="50%" valign="top">
                <div id="div_l">

                </div>
            </td>

            <td width="50%" valign="top">
                <div id="div_r">

                </div>
            </td>
        </tr>
        </tbody>
    </table>
    <%--<div class="cover_scroll"></div>--%>
</div>
<script>
    //点击切换视图
    $(document).on('click','.toggle',function () {
        window.location.href='/workflow/work/addwork'
    })
    //新建工作
    function newWorkFlow(flowId,cb){
        $.ajax({
            url:'../../workflow/work/workfastAdd',
            type:'get',
            dataType:'json',
            data:{
                flowId:flowId,
                prcsId : 1,
                flowStep : 1,
                runId:'',
                preView:0
            },
            async: false,//同步请求,这里使用ajax必须使用同步方式请求，因为浏览器认为这种打开在ajax后新页面是不安全的
            success:function(res){
                if(res.flag==true){
                    var data = res.object;
                    cb(data);
                }
            }
        });
    }
    function clickExport(e){
        layer.load();
        var flowId = e.attr('flowId')||'';
        var formId = e.attr('formId')||'';
        $.ajax({
            url:"/form/formType",
            type:'post',
            data:{
                fromId:formId
            },
            dataType:'json',
            success:function(res){
                var html = res.object.printModel;
                $('.hideenHTML').html(html);
                var arr = [];
                var $form_item = $('.hideenHTML').find(' .form_item');
                var length = $form_item.length;
                for(var i=0;i<length;i++){
                    var name = $form_item.eq(i).attr('name');
                    var title = $form_item.eq(i).attr('title');
                    var object = {
                        'key':name,
                        'value':title
                    };
                    arr.push(object);
                };
                arr = JSON.stringify(arr);
                exportajax(flowId,arr);
            }
        });
    }
    function exportajax(flowId,arr){
        //window.location.href='/flowRun/exportFlowData?flowId='+ flowId +'&formdata='+arr;
        layer.closeAll();
        $.ajax({
            url:"/flowRun/saveFlowData",
            type:'post',
            data:{
                flowId:flowId,
                formdata:arr
            },
            success:function(res){
                if(res.flag){
                    if(res.attributes.state == 1){
                        window.location.href='/flowRun/exportFlowData?flowId='+ flowId;
                        layer.closeAll();
                    }else{
                        layer.msg(res.attributes.message,{icon:2});
                    }
                }else{
                    layer.closeAll();
                }
            }
        });
    }
    function _resize(module_id) {
        var module_i=$("#module_"+module_id);
        var head_i=$("#module_"+module_id+"_head");
        var body_i=$("#module_"+module_id+"_body");
        var img_i=$("#img_resize_"+module_id);
        if(body_i.is(":hidden")){
            module_i.removeClass("listColorCollapsed");
            head_i.removeClass("moduleHeaderCollapsed");
            body_i.show();
            img_i.attr('src','/img/workflow/flowRun/icon-03_xia.png');
            img_i.attr('title','折叠');
        }else {
            module_i.addClass("listColorCollapsed");
            head_i.addClass("moduleHeaderCollapsed");
            body_i.hide();
            img_i.attr('src','/img/workflow/flowRun/icon-03_you.png');
            img_i.attr('title','展开');
        }
    }
    function openWork(sortId,me) {
        if($(me).next().find('.isClick').length==0){
            $.ajax({
                url:'../../flow/flowAuthOrSearch',
                type:'get',
                dataType:'json',
                data:{
                    sortId:sortId
                },
                success:function(obj){
                    var data=obj.obj;
                    var str='';
                    renderData(data,me);
                }
            })
        }

    }
    function renderData(data,me) {
        var str='';
        for(var i=0;i<data.length;i++){
            if(data[i].runName){
                str+='<div class="sort_new" tid='+data[i].flowId+' tableName="'+data[i].sortMainType+'" formId='+data[i].formId+' sortId='+data[i].flowSort+' freePreset="'+ data[i].freePreset +'" forcePreSet="'+ data[i].forcePreSet +'"><div class="rig_left">'+
                    '<div flowId='+data[i].flowId+' class="namenew" newType="'+function(){
                        if(data[i].newType != undefined && data[i].newType.indexOf('0')<0){
                            return '1'
                        }else{
                            return '0'
                        }
                    }()+'" title="'+data[i].flowName+'">'+data[i].flowName+'</div></div>'+
                    /*'<div class="rig_mid">'+
                    '<div class="liucheng" flowId='+data[i].flowId+'><img src="../../img/workflow/work/add_work/sheji.png" alt="" title="设计流程图"></div>'+
                    '<div class="liucheng1" flowId='+data[i].flowId+'><img src="../../img/workflow/work/add_work/liucheng.png" alt="" title="表单模板"></div>'+
                    '<div class="liucheng2"><img src="../../img/workflow/work/add_work/speak.png" alt="" title="流程说明"></div></div>'+
                    '<div class="rig_rig">'+function(){
                        if(data[i].newType == undefined){
                            return '<div class="quick" onclick="quick($(this))" tableName="'+data[i].sortMainType+'" flowId='+data[i].flowId+'><span class="xinjian_h1" id="quick_new" ><fmt:message code="newWork.th.QuickBuild" /></span></div>'
                        }else if(data[i].newType != undefined && data[i].newType.indexOf('0')>-1) {
                            return '<div class="quick" onclick="quick($(this))" tableName="'+data[i].sortMainType+'" flowId='+data[i].flowId+'><span class="xinjian_h1" id="quick_new" ><fmt:message code="newWork.th.QuickBuild" /></span></div>'
                        }else{
                            return ""
                        }

                    }()+function(){
                        if(data[i].newType == undefined){
                            return '<div class="xiangdao" flowId='+data[i].flowId+' tableName="'+data[i].sortMainType+'" style="text-align: center;"><span><fmt:message code="newWork.th.NewWizard" /></span></div>'
                        }else if(data[i].newType != undefined && data[i].newType.indexOf('1')>-1){
                            return '<div class="xiangdao" flowId='+data[i].flowId+' tableName="'+data[i].sortMainType+'" style="text-align: center;"><span><fmt:message code="newWork.th.NewWizard" /></span></div>'
                        }else{
                            return ""
                        }
                    }()+
                    '</div>' +*/
                    '</div>'
            }else{
                str+='<div class="sort_new" tid='+data[i].flowId+' tableName="'+data[i].sortMainType+'" formId='+data[i].formId+' sortId='+data[i].flowSort+' freePreset="'+ data[i].freePreset +'" forcePreSet="'+ data[i].forcePreSet +'"><div class="rig_left">'+
                    '<div flowId='+data[i].flowId+' class="namenew" newType="'+function(){
                        if(data[i].newType != undefined && data[i].newType.indexOf('0')<0){
                            return '1'
                        }else{
                            return '0'
                        }
                    }()+'" title="'+data[i].flowName+'">'+data[i].flowName+'</div></div>'+
                    /*'<div class="rig_mid">'+
                    '<div class="liucheng" flowId='+data[i].flowId+'><img src="../../img/workflow/work/add_work/sheji.png" alt="" title="设计流程图"></div>'+
                    '<div class="liucheng1"><img src="../../img/workflow/work/add_work/liucheng.png" alt="" title="表单模板"></div>'+
                    '<div class="liucheng2"><img src="../../img/workflow/work/add_work/speak.png" alt="" title="流程说明"></div></div>'+
                    '<div class="rig_rig">'+function(){
                        if(data[i].newType == undefined){
                            return '<div class="quick" onclick="quick($(this))" tableName="'+data[i].sortMainType+'" flowId='+data[i].flowId+'><span class="xinjian_h1" id="quick_new" ><fmt:message code="newWork.th.QuickBuild" /></span></div>'
                        }else if(data[i].newType != undefined && data[i].newType.indexOf('0')>-1) {
                            return '<div class="quick" onclick="quick($(this))" tableName="'+data[i].sortMainType+'" flowId='+data[i].flowId+'><span class="xinjian_h1" id="quick_new" ><fmt:message code="newWork.th.QuickBuild" /></span></div>'
                        }else{
                            return ""
                        }

                    }()+ function(){
                        if(data[i].newType == undefined){
                            return '<div class="xiangdao" flowId='+data[i].flowId+' tableName="'+data[i].sortMainType+'" style="text-align: center;"><span><fmt:message code="newWork.th.NewWizard" /></span></div>'
                        }else if(data[i].newType != undefined && data[i].newType.indexOf('1')>-1){
                            return '<div class="xiangdao" flowId='+data[i].flowId+' tableName="'+data[i].sortMainType+'" style="text-align: center;"><span><fmt:message code="newWork.th.NewWizard" /></span></div>'
                        }else{
                            return ""
                        }
                    }()+'</div>' +*/
                    '</div>'
            }
        }
        $(me).next().html(str);
    }
    function _resizeCchild(module_id) {
        var ul_i = $("#module_"+module_id+"_ul");
        var img_i = $("#img_resize_"+module_id);
        if(ul_i.is(":hidden")) {
            img_i.attr('src','/img/workflow/flowRun/icon-03_xia.png');
            img_i.attr('title','折叠');
            ul_i.show() ;
        }
        else {
            img_i.attr('src','/img/workflow/flowRun/icon-03_you.png');
            img_i.attr('title','展开');
            ul_i.hide() ;

        }
    }
    $(function(){
        var index = layer.load();
        $.ajax({
            url:"/workflow/flowclassify/flowByAuth",
            type:'post',
            dataType:'json',
            success:function(res){
                if(res.flag){
                    var str_left = '',str_right = '',data = res.datas,index_num = 0;
                    res.datas.forEach(function(firstElement,firstIndex){//第一层
                        var num1 = firstIndex%2 ==0?1:2;//判断当前项为奇数项或者偶数项
                        var firstchild = '';
                        var firstflowtype = '';
                        if(firstElement.childs.length > 0){//第二层
                            var secondchild = '';
                            var secondflowtype = '';
                            for(var i=0;i<firstElement.childs.length;i++){
                                if(firstElement.childs[i].childs.length > 0){//第三层
                                    var thirdchild = '';
                                    var thirdflowtype = '';
                                    for(var j=0;j<firstElement.childs[i].childs.length;j++){
                                        if(firstElement.childs[i].childs[j].childs.length > 0){//第四层,现在后台无法返回第四层结构数据

                                        }
                                        /*if(firstElement.childs[i].childs[j].flowTypeModels.length > 0){
                                            for(var z=0;z<firstElement.childs[i].childs[j].flowTypeModels.length;z++){
                                                if(firstElement.childs[i].flowTypeModels.length != 0 && firstElement.childs[i].flowTypeModels[j] != undefined &&flowTypeModels[z].handling != undefined && firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].handling != ''){
                                                    var work = '<span class="color2">■</span>'+ firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].handling +'   ';
                                                }else{
                                                    var work = '';
                                                }
                                                if(firstElement.childs[i].flowTypeModels.length != 0 &&  firstElement.childs[i].flowTypeModels[j] != undefined  && firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].end != undefined&&firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].end != ''){
                                                    var end = '<span class="color3">■</span>'+ firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].end;
                                                }else{
                                                    var end = '';
                                                }
                                                if(firstElement.childs[i].flowTypeModels.length != 0 && firstElement.childs[i].flowTypeModels[j] != undefined && firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowType == 1){
                                                    var flowtype = '固定';
                                                }else if(firstElement.childs[i].flowTypeModels.length != 0 && firstElement.childs[i].flowTypeModels[j] != undefined && firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowType == 2){
                                                    var flowtype = '自由';
                                                }else{
                                                    var flowtype = '';
                                                }
                                                if(firstElement.childs[i].flowTypeModels.length != 0 && firstElement.childs[i].flowTypeModels[j] != undefined &&  firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowDoc == 0){
                                                    var flowDoc = '否';
                                                }else if(firstElement.childs[i].flowTypeModels.length != 0 && firstElement.childs[i].flowTypeModels[j] != undefined && firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowDoc == 1){
                                                    var flowDoc = '是';
                                                }else{
                                                    var flowDoc = '';
                                                }
                                                if(firstElement.childs[i].flowTypeModels.length != 0){
                                                    if(firstElement.childs[i].flowTypeModels[j] != undefined ) {
                                                        thirdflowtype += '<li><a href="allSearchList?FLOW_ID=' + firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowId + '" title="流程类型：' + flowtype + '\n\
允许附件：' + flowDoc + '">' + firstElement.childs[i].flowTypeModels[j].flowTypeModels[z].flowName + '</a>&nbsp;&nbsp;&nbsp;' + work + end + '</li>'
                                                    }
                                                }else{
                                                    thirdflowtype += '';
                                                }

                                            }
                                        }*/
                                        secondchild += '<span style="cursor:pointer;display:block;" class="isClick" onclick="_resizeCchild('+ index_num +');openWork('+firstElement.childs[i].childs[j].sortId+',this)"><img style="margin-left:0px;margin-bottom:4px" class="zi icon" id="img_resize_'+ index_num +'" src="/img/workflow/flowRun/icon-03_xia.png" title="_(&quot;折叠&quot;)"><span id="module_'+ index_num +'_text" class="text">'+ firstElement.childs[i].childs[j].sortName +'</span></span><ul style="margin-left:15px;" id="module_'+ index_num +'_ul">'+ thirdflowtype+thirdchild +'</ul>'
                                        thirdflowtype = '';
                                        thirdchild = '';
                                        index_num++;
                                    }
                                }
                                /* if(firstElement.childs[i].flowTypeModels.length > 0){
                                     for(var j=0;j<firstElement.childs[i].flowTypeModels.length;j++){
                                         if(firstElement.childs[i].flowTypeModels[j].handling != undefined&&firstElement.childs[i].flowTypeModels[j].handling != ''){
                                             var work = '<span class="color2">■</span>'+ firstElement.childs[i].flowTypeModels[j].handling +'   ';
                                         }else{
                                             var work = '';
                                         }
                                         if(firstElement.childs[i].flowTypeModels[j].end != undefined&&firstElement.childs[i].flowTypeModels[j].end != ''){
                                             var end = '<span class="color3">■</span>'+ firstElement.childs[i].flowTypeModels[j].end;
                                         }else{
                                             var end = '';
                                         }
                                         if(firstElement.childs[i].flowTypeModels[j].flowType == 1){
                                             var flowtype = '固定';
                                         }else if(firstElement.childs[i].flowTypeModels[j].flowType == 2){
                                             var flowtype = '自由';
                                         }else{
                                             var flowtype = '';
                                         }
                                         if(firstElement.childs[i].flowTypeModels[j].flowDoc == 0){
                                             var flowDoc = '否';
                                         }else if(firstElement.childs[i].flowTypeModels[j].flowDoc == 1){
                                             var flowDoc = '是';
                                         }else{
                                             var flowDoc = '';
                                         }
                                         secondflowtype += '<li><a href="allSearchList?FLOW_ID='+ firstElement.childs[i].flowTypeModels[j].flowId +'" title="流程类型：'+ flowtype +'\n\
 允许附件：'+ flowDoc +'">'+ firstElement.childs[i].flowTypeModels[j].flowName +'</a>&nbsp;&nbsp;&nbsp;'+ work+end +'</li>'
                                     }
                                 }*/
                                firstchild += '<span style="cursor:pointer;display:block;" class="isClick" onclick="_resizeCchild('+ index_num +');openWork('+firstElement.childs[i].sortId+',this)"><img style="margin-left:0px;margin-bottom:4px" class="zi icon" id="img_resize_'+ index_num +'" src="/img/workflow/flowRun/icon-03_xia.png" title="_(&quot;折叠&quot;)"><span id="module_'+ index_num +'_text" class="text">'+ firstElement.childs[i].sortName +'</span></span><ul style="margin-left:15px;" id="module_'+ index_num +'_ul">'+ secondflowtype+secondchild +'</ul>'
                                secondflowtype = '';
                                secondchild = '';
                                index_num++;
                            }
                        }
                        /*    if(firstElement.flowTypeModels.length > 0){
                                for(var j=0;j<firstElement.flowTypeModels.length;j++){
                                    if(firstElement.flowTypeModels[j].handling != undefined&&firstElement.flowTypeModels[j].handling != ''){
                                        var work = '<span class="color2">■</span>'+ firstElement.flowTypeModels[j].handling +'   ';
                                    }else{
                                        var work = '';
                                    }
                                    if(firstElement.flowTypeModels[j].end != undefined&&firstElement.flowTypeModels[j].end != ''){
                                        var end = '<span class="color3">■</span>'+ firstElement.flowTypeModels[j].end;
                                    }else{
                                        var end = '';
                                    }
                                    if(firstElement.flowTypeModels[j].flowType == 1){
                                        var flowtype = '固定';
                                    }else if(firstElement.flowTypeModels[j].flowType == 2){
                                        var flowtype = '自由';
                                    }else{
                                        var flowtype = '';
                                    }
                                    if(firstElement.flowTypeModels[j].flowDoc == 0){
                                        var flowDoc = '否';
                                    }else if(firstElement.flowTypeModels[j].flowDoc == 1){
                                        var flowDoc = '是';
                                    }else{
                                        var flowDoc = '';
                                    }

                                    firstflowtype += '<li><a href="allSearchList?FLOW_ID='+ firstElement.flowTypeModels[j].flowId +'" title="流程类型：'+ flowtype +'\n\
    允许附件：'+ flowDoc +'">'+ firstElement.flowTypeModels[j].flowName +'</a>&nbsp;&nbsp;&nbsp;'+ work+end +'</li>'
                                }
                            }*/
                        var img_i='/img/workflow/flowRun/icon-03_you.png';
                        var title='展开';
                        var dis='none';
                        var classSty='listColorCollapsed moduleHeaderCollapsed'
                        if(firstElement.childs.length!=0) {
                            classSty=''
                            img_i='/img/workflow/flowRun/icon-03_xia.png';
                            title='折叠';
                            dis='block';
                        }

                        if(num1 == 1){
                            str_left +=  '<div id="module_'+ index_num +'" class="module color_style_4 listColor '+classSty+'">\
                                            <div class="head" class="isClick" onclick="_resize('+ index_num +');openWork('+firstElement.sortId+',this)" style="cursor:pointer">\
                                                <h4 id="module_'+ index_num +'_head" class="moduleHeader">\
                                                    <img style="margin-bottom:0px" class="zi icon" id="img_resize_'+ index_num +'" src="'+img_i+'" title="'+title+'"><span id="module_'+ index_num +'_text" class="text">'+ firstElement.sortName +'</span>\
                                                </h4>\
                                            </div>\
                                            <div id="module_'+ index_num +'_body" class="module_body" style="display:'+dis+';">\
                                                <div id="module_'+ index_num +'_ul" class="module_div">\
                                                    <ul>'+ firstflowtype+firstchild +'</ul>\
                                                </div>\
                                            </div>\
                                        </div>';
                            index_num++;
                        }else{
                            str_right +=  '<div id="module_'+ index_num +'" class="module color_style_4 listColor '+classSty+'">\
                                            <div class="head" class="isClick" onclick="_resize('+ index_num +');openWork('+firstElement.sortId+',this)" style="cursor:pointer">\
                                                <h4 id="module_'+ index_num +'_head" class="moduleHeader">\
                                                    <img style="margin-bottom:0px" class="zi icon" id="img_resize_'+ index_num +'" src="'+img_i+'" title="'+title+'"><span id="module_'+ index_num +'_text" class="text">'+ firstElement.sortName +'</span>\
                                                </h4>\
                                            </div>\
                                            <div id="module_'+ index_num +'_body" class="module_body" style="display:'+dis+';">\
                                                <div id="module_'+ index_num +'_ul" class="module_div">\
                                                    <ul>'+ firstflowtype+firstchild +'</ul>\
                                                </div>\
                                            </div>\
                                        </div>';
                            index_num++;
                        }
                    })
                }else{

                }
                $('#div_l').html(str_left);
                $('#div_r').html(str_right);
                $('.tablebox').show();
                layer.close(index);
                $('.isClick').each(function () {
                    // console.log($(this))
                    $(this).click()
                })
            }
        })
    })
    //点击名称快速新建页面
    $(document).on('click','.namenew',function(){
        var _this = $(this);
        var newType = $(this).attr('newType');
        var forcePreSet = _this.parents('.sort_new').attr('forcePreSet')||'';
        var freepreset = _this.parents('.sort_new').attr('freepreset')||'';
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        if(freepreset == '1'&&(forcePreSet == '2'||forcePreSet == '3'||forcePreSet == '4')){
            if(forcePreSet == '2'){
                var calc = '此工作要求强制输入前缀，确定进入新建向导？';
            }else if(forcePreSet == '3'){
                var calc = '此工作要求强制输入后缀，确定进入新建向导？';
            }else if(forcePreSet == '4'){
                var calc = '此工作要求强制输入前缀和后缀，确定进入新建向导？';
            }
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
                    if(res.flag){
                        var flowId=_this.attr('flowId');
                        if(tableName == 'BUDGETTYPE'){
                            $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                        }else{
                            $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                        }

                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }else{
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
					console.log(123);
                    if(res.flag){
                        var flowId= _this.attr('flowId');
                        user_id='quick';
                        if(newType == '0'){
                            newWorkFlow(flowId,function (data) {
                                if(data.sortMainType=='BUDGETTYPE'){
									parent.location.href="/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId;
                                    //$.popWindow("/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                                }else{
									parent.location.href="/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId;
                                  //  $.popWindow("/workflow/work/workform?flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                                }

                            })
                        }

                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }


    });
    //点击流程设计图
    $(document).on('click','.liucheng',function(){
        var flowId=$(this).attr('flowId');
        window.open('/flowSetting/processDesignToolsT?flowId='+flowId+'&type=0','流程设计器预览','width='+(window.screen.availWidth)+',height='+(window.screen.availHeight)+',top=0,left=0,scrollbars=no,resizable=no');
    })
    //点击流程表单
    $(document).on('click','.liucheng1',function(){
        var flowId= $(this).attr('flowId');
        var formId=$(this).parents('.sort_new').attr('formid');
        user_id='quick';
        $.popWindow('/workflow/work/workform1?formId='+formId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
    })
    //点击流程说明
    $(document).on('click','.liucheng2',function(){
        var flowId=$(this).parents('.sort_new').attr('tid');
        var formId=$(this).parents('.sort_new').attr('formid');
        var word=$(this).parent().siblings('.rig_left').find('h1').text();
        $.popWindow("/workflow/work/processSpeak?flowId="+flowId+'&formId='+formId,'流程说明-'+word+'','0','0','1150px','700px');
    })
    //点击出现快速新建页面
    function quick(e){
        var _this = e;
        var forcePreSet = _this.parents('.sort_new').attr('forcePreSet')||'';
        var freepreset = _this.parents('.sort_new').attr('freepreset')||'';
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        if(freepreset == '1'&&(forcePreSet == '2'||forcePreSet == '3'||forcePreSet == '4')){
            if(forcePreSet == '2'){
                var calc = '此工作要求强制输入前缀，确定进入新建向导？';
            }else if(forcePreSet == '3'){
                var calc = '此工作要求强制输入后缀，确定进入新建向导？';
            }else if(forcePreSet == '4'){
                var calc = '此工作要求强制输入前缀和后缀，确定进入新建向导？';
            }
            var r = confirm(calc);
            if (r==true){
                $.ajax({
                    url:'/userCountPer',
                    dataType:'json',
                    type:'get',
                    success:function(res){
                        if(res.flag){
                            var flowId=_this.attr('flowId');
                            if(tableName == 'BUDGETTYPE'){
                                $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }else{
                                $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }

                        }else{
                            $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                        }
                    }
                })
            }else{

            }
        }else{
            $.ajax({
                url:'/userCountPer',
                dataType:'json',
                type:'get',
                success:function(res){
                    if(res.flag){
                        var flowId= _this.attr('flowId');
                        user_id='quick';
                        newWorkFlow(flowId,function (data) {
                            if(data.sortMainType=='BUDGETTYPE'){
                                $.popWindow("/workflow/work/workform?opflag=1&flowId="+flowId+'&type=new&flowStep=1&prcsId=1&tableName=budget&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }else{
                                $.popWindow("/workflow/work/workform?opflag=1&flowId="+flowId+'&type=new&flowStep=1&prcsId=1&runId='+data.flowRun.runId,'<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                            }

                        })
                    }else{
                        $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                    }
                }
            })
        }


    };
    //点击新建向导
    $(document).on('click','.xiangdao',function(){
        var _this = $(this);
        var tableName = _this.parents('.sort_new').attr('tableName')||'';
        $.ajax({
            url:'/userCountPer',
            dataType:'json',
            type:'get',
            success:function(res){
                if(res.flag){
                    var flowId=_this.attr('flowId');
                    if(tableName == 'BUDGETTYPE'){
                        $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&tableName=budget&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                    }else{
                        $.popWindow("/workflow/work/newflowguider?flowId="+flowId+'&flowStep=1&prcsId=1','<fmt:message code="newWork.th.Quick" />','0','0','1150px','700px');
                    }
                }else{
                    $.layerMsg({content:'人数达到上限，不能新建',icon:6})
                }
            }
        })
	
    })
	
</script>

</body>
</html>
